#!/sbin/openrc-run
# Distributed under the terms of the GNU General Public License v2

depend() {
	need xenstored xenconsoled
}

start() {
	ebegin "Starting QEMU as disk backend for dom0"
	# XXX: qemu f**** the console when launched with
	# -nographic and -monitor, use nohup to prevent that.
	start-stop-daemon --start --exec nohup \
		--pidfile=/run/xenqemu.pid -b -- \
		/usr/lib/xen/bin/qemu-system-i386 \
		-xen-domid 0 -xen-attach -name dom0 -nographic \
		-M xenpv -monitor /dev/null \
		-pidfile /run/xenqemu.pid \
		${XENQEMU_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping QEMU as disk backend for dom0"
	start-stop-daemon --stop --exec /usr/lib/xen/bin/qemu-system-i386 \
		--pidfile /run/xenqemu.pid
	eend $?
}

